package com.battle.service.controller.web;

import com.battle.pojo.param.caseBaseInfo.CaseStatisticsParam;
import com.battle.pojo.param.caseBaseInfo.GetCaseDiscountingParam;
import com.battle.pojo.param.warCaseStudy.*;
import com.battle.pojo.vo.caseBaseInfo.CaseCakeVo;
import com.battle.pojo.vo.caseBaseInfo.CaseDiscountingVo;
import com.battle.pojo.vo.caseBaseInfo.CaseRankingListVo;
import com.battle.pojo.vo.caseBaseInfo.CaseStatisticsVo;
import com.battle.pojo.vo.warCaseStudy.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/战例研讨
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/warCaseStudy/web")
public class WarCaseStudyWebController {

    private final WarCaseStudyService service;

    public WarCaseStudyWebController(WarCaseStudyService service) {
        this.service = service;
    }


    /**
     * 创建战例研讨
     *
     * @param param
     * @return
     */
    @PostMapping("/createWarCaseStudy")
    public ApiResult createWarCaseStudy(@RequestBody @Valid CreateWarCaseStudyParam param) {
        service.createWarCaseStudy(param);
        return ApiResult.ok();
    }

    /**
     * 结束战例研讨
     *
     * @param param
     * @return
     */
    @PostMapping("/editWarCaseStudy")
    public ApiResult editWarCaseStudy(@RequestBody @Valid EditWarCaseStudyParam param) {
        service.editWarCaseStudy(param);
        return ApiResult.ok();
    }

    /**
     * 邀请用户战例研讨
     *
     * @param param
     * @return
     */
    @PostMapping("/inviteCaseStudy")
    public ApiResult inviteCaseStudy(@RequestBody @Valid InviteCaseStudyParam param) {
        service.inviteCaseStudy(param);
        return ApiResult.ok();
    }

    /**
     * 移除战例研讨
     *
     * @param id
     */
    @DeleteMapping("/removeWarCaseStudy")
    public ApiResult removeWarCaseStudy(@RequestParam("id") Long id) {
        service.removeWarCaseStudy(id);
        return ApiResult.ok();
    }

    /**
     * 报名战例研讨
     * @param studyId
     * @param userId
     * @return
     */
    @GetMapping("/applyCaseStudy")
    public ApiResult applyCaseStudy(@RequestParam("studyId") Long studyId,@RequestParam("userId") Long userId) {
        service.applyCaseStudy(studyId, userId);
        return ApiResult.ok();
    }

    /**
     * 获取战例研讨详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getWarCaseStudy")
    public ApiResult<GetWarCaseStudyVo> getWarCaseStudy(@RequestParam("id") Long id) {
        GetWarCaseStudyVo vo = service.getWarCaseStudy(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取战例研讨列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getWarCaseStudyList")
    public ApiResult<PageResult<GetWarCaseStudyListVo>> getWarCaseStudyList(@RequestBody GetWarCaseStudyListParam param) {
        PageResult<GetWarCaseStudyListVo> result = service.getWarCaseStudyList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取战例研讨下拉列表
     *
     * @return
     */
    @PostMapping("/getWarCaseStudyDownList")
    public ApiResult<List<GetWarCaseStudyDownListVo>> getWarCaseStudyDownList(@RequestBody(required = false) @Valid GetWarCaseStudyDownListParam param) {
        List<GetWarCaseStudyDownListVo> list = service.getWarCaseStudyDownList(param);
        return ApiResult.ok(list);
    }


    /**
     * 查看研讨成果
     *
     * @param id
     * @return
     */
    @GetMapping("/getWarCaseResult")
    public ApiResult<EditWarCaseStudyParam> getEditWarCaseStudyParam(@RequestParam("id") Long id) {
        EditWarCaseStudyParam vo = service.getEditWarCaseStudyParam(id);
        return ApiResult.ok(vo);
    }

    /**
     * 修改研讨成果
     * @param param
     * @return
     */
    @PostMapping("/editWarCaseResult")
    public ApiResult<EditWarCaseStudyParam> editWarCaseResult(@RequestBody EditWarCaseStudyParam param) {
        service.editWarCaseResult(param);
        return ApiResult.ok();
    }

    /**
     * 删除研讨成果
     *
     * @param id
     * @return
     */
    @GetMapping("/removeWarCaseResult")
    public ApiResult removeWarCaseResult(@RequestParam("id") Long id) {
        service.removeWarCaseResult(id);
        return ApiResult.ok();
    }



    /**
     * 战例统计数量-顶部四个
     * @return
     */
    @GetMapping("/getCaseStatistics")
    public ApiResult<CaseStatisticsVo> getCaseStatistics() {
        CaseStatisticsVo vo = service.getCaseStatistics();
        return ApiResult.ok(vo);
    }

    /**
     * 战例研讨排行榜
     * @return
     */
    @GetMapping("/getCaseRankingList")
    public ApiResult<List<CaseRankingListVo>> getCaseRankingList() {
        List<CaseRankingListVo> vo = service.getCaseRankingList();
        return ApiResult.ok(vo);
    }


    /**
     * 战例|研讨类别统计饼图
     *
     * @return
     */
    @PostMapping("/getCaseCake")
    public ApiResult<CaseCakeVo> getCaseCake(@RequestBody(required = false) @Valid CaseStatisticsParam param) {
        CaseCakeVo list = service.getCaseCake(param);
        return ApiResult.ok(list);
    }

    /**
     * 战例|研讨折线图
     *
     * @return
     */
    @PostMapping("/getCaseDiscounting")
    public ApiResult<CaseDiscountingVo> getCaseDiscounting(@RequestBody(required = false) @Valid GetCaseDiscountingParam param) {
        CaseDiscountingVo list = service.getCaseDiscounting(param);
        return ApiResult.ok(list);
    }
}

